<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        p {
            width: 340px;
            height: 40px;
            margin-bottom: 25px;
        }

        input,
        button {
            box-sizing: border-box;
            width: 100%;
            height: 100%;
        }

        input {
            padding-left: 50px;
        }

        button {
            cursor: pointer;
        }

        .login {
            width: 340px;
            margin: 100px auto;
        }
    </style>
</head>

<body>
    <div class="login">
        <p><input type="text" id="name" placeholder="username"></p>
        <p><input type="password" placeholder="password"></p>
        <p><button id="btn">登录</button></p>
    </div>

    <script>
        function $(selector) {
            return document.getElementById(selector);
        }
        $("btn").onclick = function () {
            console.log($("name"));
        }
    </script>
</body>

</html>